// 密钥对生成 http://web.chacuo.net/netrsakeypair

import JSEncrypt from 'jsencrypt/bin/jsencrypt.min';

// 生成的公钥（修改密码）
const publicKey1 =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCIAvA/VFJqZldxkn1FscTCJwqqb9xS422ju3YsCM9yo/bGbbX9LjWPqm8d20SVLQv+x0ONZDCSt5rVk9hmZqM98GL/Jwr0YjYsggvHs/fUOw+cr8XZumTctJ6+seWl9eAQyusYrEXSpgm5n9FbXK025okzNcEQx3sSPcQY4dKhLQIDAQAB';
// 生成的公钥（权限管理-设置密码 && 银证转账 - 银行密码，资金密码）
const publicKey2 =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCe0+WD7kqkmPTHHw5OSzH9rQ2vAQ8gKfALpM87pEFSTzCj/Q4xyz8bSOef9MzAeYX3GcrwEwWyExTDvX+Qi+A49ujxnHG6jlfX+dwLOUDBMORxJZtt0QoKbQHh6RFeMXveXvUpCuVoY3jhmyAPK4K9vbmGctpBFmCRh5x5lIbH7QIDAQAB';

// 加密
export function encrypt(txt, type) {
  const encryptor = new JSEncrypt();
  let publicKey = '';
  if (type === 1) {
    publicKey = publicKey1;
  } else if (type === 2) {
    publicKey = publicKey2;
  }
  encryptor.setPublicKey(publicKey); // 设置公钥
  return encryptor.encrypt(txt); // 对数据进行加密
}

// 解密
// export function decrypt (txt) {
//   const encryptor = new JSEncrypt();
//   encryptor.setPrivateKey(privateKey); // 设置私钥
//   return encryptor.decrypt(txt); // 对数据进行解密
// }
